<?php
namespace mobadmin\action;

use herosphp\bean\Beans;
use herosphp\core\Log;
use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;

/**
 * 个人中心 index 控制器
 */
class IndexAction extends CommonAction {


    public $manager;
    public function __construct()
    {
        parent::__construct();
        $this -> manager = Beans::get("mobadmin.manager.service");
    }

    /**
     * 首页方法
     * @param HttpRequest $request
     */
    public function index(HttpRequest $request) {

        //个人信息
        $managerItem = $this->manager->getLoginManager();
        $this -> assign('manager',$managerItem);
        //报价信息
        $offerService = Beans::get('offer.offer.service');
        $offerTotal = $offerService -> count(['saas_user_id'=>$managerItem['id']]);
        $views = $offerService -> sum(['saas_user_id'=>$managerItem['id']],"views");
        $views = $views?$views:0;
        //浏览增加
        if(1<=$views&&$views<=30){

            $views=$views*3;

        }elseif(31<=$views&&$views<=70){

            $views=$views*2;

        }elseif(71<=$views&&$views<=100){

            $views=$views*1;
        }


        $this->assign('offerTotal',$offerTotal);
        $this->assign('viewTotal',$views);
        $this->assign("title", "个人中心");
        $this->setView("index");

    }

}
